(defpackage :black-pine
  (:use #:cl #:cffi)
  (:export #:black-pine
	   #:delete_blackpine	  
	   #:set-left-delimiter
	   #:get-left-delimiter	   
	   #:set-right-delimiter
	   #:get-right-delimiter
	   #:set-template-dir
	   #:get-template-dir
	   #:set-plugin-dir
	   #:get-plugin-dir
	   #:assign
	   #:display
	   #:to-string
	   #:load-config	   
	   #:with-black-pine
	   )
  )
(in-package :black-pine)

(cffi:define-foreign-library libbp
  (:unix "./black-pine.so")
  )
(cffi:load-foreign-library 'libbp)

(defmacro with-black-pine ((bp) &body body)
  `(let ((,bp (make-instance 'black-pine)))
     (unwind-protect
          (progn
            ,@body
            )
       (if ,bp (delete_blackpine (slot-value ,bp 'ff-pointer)))
       )
     )
  )
